package HomeWork;

import java.util.concurrent.TimeUnit;

public class ATM {
private int aMoney=1000;
public  static int a;



    public   void A(){
        for (int i = 1; i < 11; i++) {
            if(aMoney>0){
                a=aMoney-100*i;
            System.out.println("A取走了100元，剩余:"+a+"元");
            try {
                TimeUnit.SECONDS.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            }
        }
    }

    public void B(){
        for (int i = 1; i < 11; i++) {
            if(aMoney>0){
                a=aMoney-100*i;
                System.out.println("B取走了100元，剩余:"+a+"元");
                try {
                    TimeUnit.SECONDS.sleep(1);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }


    public static void main(String[] args) {
        ATM atm=new ATM();
        new Thread(()->atm.A()).start();
        new Thread(()->atm.B()).start();

    }

}

